package com.xfcy.blog.controller.system;



import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.dev33.satoken.annotation.SaCheckPermission;
import com.xfcy.blog.annotation.OperationLogger;
import com.xfcy.blog.common.R;
import com.xfcy.blog.service.MessageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;

/**
 * (Message)表控制层
 *
 * @author 晓风残月Lx
 * @since 2023-04-09 11:03:05
 */
@RestController
@RequestMapping("system/message")
@Api(tags = "留言管理")
public class MessageController {

    @Resource
    private MessageService messageService;

    @SaCheckLogin
    @ApiOperation(value = "留言列表", httpMethod = "GET", response = R.class, notes = "留言列表")
    @GetMapping("/list")
    public R list(Integer pageNo, Integer pageSize, String name) {
        return messageService.listMessage(pageNo, pageSize, name);
    }

    @OperationLogger(value = "删除留言")
    @SaCheckPermission("/system/message/remove")
    @DeleteMapping("/remove")
    @ApiOperation(value = "删除留言", httpMethod = "DELETE", response = R.class, notes = "删除留言")
    public R delete(Integer id) {
        return messageService.deleteBatchMessage(Collections.singletonList(id));
    }

    @OperationLogger(value = "批量删除留言")
    @SaCheckPermission("/system/message/deleteBatch")
    @DeleteMapping("/deleteBatch")
    @ApiOperation(value = "批量删除留言", httpMethod = "DELETE", response = R.class, notes = "批量删除留言")
    public R deleteBatchMessage(@RequestBody List<Integer> ids) {
        return messageService.deleteBatchMessage(ids);
    }

    @OperationLogger(value = "批量通过")
    @RequestMapping(value="/passBatch",method = RequestMethod.POST)
    @SaCheckPermission("/system/message/passBatch")
    @ApiOperation(value = "批量通过", httpMethod = "POST", response = R.class, notes = "批量通过")
    public R passBatch(@RequestBody List<Integer> ids){
        return messageService.passBatch(ids);
    }


}

